package com.jiayu.wheel.aop;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/aop")
public class AopLogController {

    private final int FIVE = 5;

    @GetMapping("/demo")
    public String demo() throws Exception {
       int a = new Random().nextInt(10);
       // 一定半几率抛异常，测试aop效果
        if(a < FIVE){
            throw new Exception("抛个异常给aop看看");
       }
        return "Hello aop";
    }

}
